package com.asyf.demo.controller;

import com.asyf.demo.common.aop.SpElDemoLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * SpEl 实现自定义日志记录
 * 参考：https://mp.weixin.qq.com/s?__biz=MzU0MjQ2MTA5NQ==&mid=2247486601&idx=1&sn=05346095b7826db9c46c7d7edd860f50&chksm=fb1b1141cc6c9857f9f81f5167210c63220dc9d0576797afd682af3fdb07bb70aa32e3c1f219&cur_album_id=1965865705375842309&scene=189#wechat_redirect
 */
@RestController
@RequestMapping(value = "/spel")
@Api(tags = "SpEl示例")
@Slf4j
public class SpElDemoController {

    @SpElDemoLog(el = "#id")
    @GetMapping(value = "spel/demo/{id}")
    @ApiOperation(value = "接口测试")
    public void get(@PathVariable("id") Integer id) {

    }

    @SpElDemoLog(el = "#user.name")
    @GetMapping(value = "spel/demo")
    @ApiOperation(value = "接口测试2")
    public void get(SecurityProperties.User user) {

    }

}
